package ${daoPackage};

import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import ${entityPackage}.${className};


public interface ${className}Mapper {

    @Select("select * from ${tableName} where ${pk.columnName} = ${r'#'}{${pk.attrname}}")
    ${className} findBy${pk.attrName}(${pk.attrType} ${pk.attrname});

<#list keys as key>
    @Select("select * from ${tableName} where ${key.columnName} = ${r'#'}{${key.attrname}}")
    ${className} findBy${key.attrName}(${key.attrType} ${key.attrname});
</#list>

    List<${className}> list(@Param("params") Map<String, Object> params, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    @Delete("delete from ${tableName} where ${pk.columnName} = ${r'#'}{${pk.attrname}}")
    int deleteById(${pk.attrType} id);

    int deleteBatch(${pk.attrType}[] ${pk.attrName}s);

    int update(${className} ${classname});

    @Options(useGeneratedKeys = true, keyProperty = "${pk.columnName}")
    @Insert("insert into ${tableName}(<#list columns as column>`${column.columnName}`,</#list> create_time, update_time) values(<#list columns as column>${r'#'}{${column.attrname}},</#list> now(), now())")
    int save(${className} ${classname});
}